var ltgt = function(text){
	return text.replace(/</gi,'&lt;').replace(/>/gi,'&gt;');
};

var set_num = function (var1,bool) {
	if(bool){
		var1=parseInt(var1);
	}
  if (isNaN(var1)) {
    return 0;
  } else {
    return Number(var1);
  }
};

var time_m = function(fn){
	var start_time = +new Date;
	fn();
	var end_time = +new Date;
	bw = end_time-start_time;
	console.log(bw);
	return new Array(start_time,end_time,bw);
};

var tt = function(){
	var v1 = arguments;
	var len = v1.length;
	var rt = [];
	for(var i=0;i<len;i++){
		rt.push(v1[i]);
	}
	return rt.join('');
};

var set_hash = function(key,val){
	data = hash();
	data[key] = val;
	edit_hash(data);
};

var remove_hash = function(key){
	if(key){
		data = hash();
		rt = [];
		for(var i in data){
			if(key!=i){
				if(data[i]){
					rt.push('#',i,'_',data[i]);
				} else {
					rt.push('#',i);
				}
			}
		}
	} else {
		rt = [];
	}
	window.location.hash = rt.join('');
};

var read_hash = function(key){
	dd = window.location.hash;
	dd = dd.split('#');
	data = [];
	for(var i in dd){
		if(i==0){continue;}
		tt = [];
		tt = dd[i].split('_');
		data[tt[0]]=(tt[1])?tt[1]:'';
	}
	if(key){
		return data[key];
	} else {
		return data;
	}
};

var edit_hash = function(data){
	rt = [];
	for(var i in data){
		if(data[i]){
			rt.push('#',i,'_',data[i]);
		} else {
			rt.push('#',i);
		}
	}

	window.location.hash = rt.join('');
};
	
var frget = function(gname){              //get값 읽는 함수.
	var get = location.search.replace('?','');
	var ar = get.split('&');
	var rt = [];
	var data;
	for(var i in ar){
		data = ar[i].split('=');
		rt[data[0]] = data[1];
	}
	if(gname){
		return rt[gname];
	} else {
		return rt;
	}
};
